<template>
  <div id="cart">
    <!-- 1.导航栏 -->
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{ length }})</div>
    </nav-bar>

    <!-- 2.商品详情 -->
    <scroll class="content" ref="scroll">
      <cart-list />
    </scroll>

    <!-- 底部汇总 -->
    <cart-buttom-bar />
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar.vue";
import Scroll from "components/common/scroll/Scroll";

// 商品详情显示
import CartList from "./childComps/CartList.vue";
//底部汇总
import CartButtomBar from "./childComps/CartButtomBar";

import { mapGetters } from "vuex";

export default {
  name: "Cart",
  components: {
    NavBar,
    Scroll,
    CartList,
    CartButtomBar,
  },
  computed: {
    //将vuex里面的getters添加到计算属性中，然后直接引用
    ...mapGetters({
      length: "cartLength",
    }),
  },
  activated() {
    //进入购物车界面进行刷新
    this.$refs.scroll.refresh();
  },
};
</script>

<style scoped>
#cart {
  z-index: 9;
  height: 100vh;
}
.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
}
.content {
  overflow: hidden;
  height: calc(100% - 44px - 49px - 40px);
}
</style>